home *** CD-ROM | disk | FTP | other *** search
- SERVICE: COMMAND KEY: ?
-
- ' PhoneBook… 6/1/87 Glenn Voloshin
-
- ' Modified 7/28/87 by Ken Walter
-
- ' Stores six sets of name, number and Communication Control settings in a
-
- ' fixed length file called MiniTerminalPhoneBook.
-
-
-
- HOLD ON
-
- CURSOR WATCH
-
- whichLine% = 0
-
- changedSettings% = FALSE%
-
-
-
- doneButton% = 29 ' dialog item numbers
-
- saveChanges% = 14
-
- startText% = 17
-
- startButtons% = 2
-
- startEdit% = 15
-
-
-
- maxLines% = 6 ' field sizes of file
-
- stringWidth% = 16
-
- numParams% = 26
-
- paramWidth% = 3
-
- paramBlockWidth% = numParams% * paramWidth%
-
- wholeBlockWidth% = (2 * stringWidth%) + paramBlockWidth%
-
- IF (@modemFile = "") OR (NOT Exists%(ServiceFPath & @modemFile)) THEN ∂
-
- GOSUB getModemFile
-
-
-
- IF NOT Exists% (ServiceFPath & "MiniTerminalPhoneBook") THEN ∂
-
- GOSUB makeFile ∂
-
- ELSE ∂
-
- OPEN 1, ServiceFPath & "MiniTerminalPhoneBook", APPEND :∂
-
- IF ResultCode% <> 0 THEN ∂
-
- badFile = "MiniTerminalPhoneBook" : ∂
-
- GOSUB fileIO_Error: ∂
-
- END
-
- Pos%(1) = maxLines% * wholeBlockWidth%
-
-
-
- GOSUB saveSettings ' saves the current Com Control settings to be
-
- HOLD OFF ' restored, if changed while modifying PhoneBook
-
- SET DBOX 406
-
- CheckBox%(1) = @Redial%
-
- GOSUB getText ' reads file into controls
-
-
-
- whichLine% = 1
-
- GOSUB setEditText ' put name & number in edit text fields
-
- Pos%(1) = (whichLine% * wholeBlockWidth%) - paramBlockWidth%
-
- GOSUB getSettings ' read settings from file into Com Control
-
- changedSettings% = TRUE%
-
- HOLD OFF
-
- DBOX 406
-
- theLoop: ' modeless dialog loop
-
- HOLD OFF
-
- CURSOR RESET
-
- theLoop1:
-
- dbr% = DBoxResult% + 2
-
- IF dbr% = 0 THEN ∂
-
- GOTO theLoop1
-
- endLoop:
-
- HOLD ON
-
- CURSOR WATCH
-
- @Redial% = CheckBox%(1)
-
-
-
- IF dbr% = doneButton% THEN ∂
-
- IF changedSettings% THEN ∂ ' restore original Com Control settings
-
- Pos%(1) = maxLines% * wholeBlockWidth% :∂
-
- GOSUB getSettings :∂
-
- CLOSE 1 :∂
-
- END ∂
-
- ELSE ∂
-
- CLOSE 1 :∂
-
- END
-
-
-
- IF dbr% = saveChanges% THEN ∂
-
- IF (whichLine% > 0) AND (whichLine% <= maxLines%) THEN ∂
-
- GOSUB doSave :∂ ' write text to file and update dialog
-
- Pos%(1) = (whichLine% * wholeBlockWidth%) - paramBlockWidth% :∂
-
- GOSUB saveSettings :∂ ' write Com Control settings to file
-
- GOTO theLoop ∂
-
- ELSE ∂
-
- GOTO theLoop
-
-
-
- whichLine% = dbr% DIV 2
-
-
-
- IF dbr% MOD 2 > 0 THEN ∂ ' a CHANGE button was pressed
-
- GOSUB setEditText :∂ ' put name & number in edit text fields
-
- Pos%(1) = (whichLine% * wholeBlockWidth%) - paramBlockWidth% :∂
-
- GOSUB getSettings :∂ ' read settings from file into Com Control
-
- changedSettings% = TRUE% :∂
-
- GOTO theLoop
-
-
-
-
-
- GOSUB doDial ' dial the PhoneBook number
-
-
-
- END
-
-
-
- doSave:
-
- aName = ButtonText(startEdit%) ' fill blank fields with "???"
-
- IF aName = "" THEN ∂
-
- aName = "???" ∂
-
- ELSE ∂
-
- aName = Left(aName, stringWidth%)
-
- ButtonText(startEdit%) = aName
-
- aNumber = ButtonText(startEdit%+1)
-
- IF aNumber = "" THEN ∂
-
- aNumber = "???" ∂
-
- ELSE ∂
-
- aNumber = Left(aNumber, stringWidth%)
-
- ButtonText(startEdit%+1) = aNumber
-
-
-
- IF (aName <> editName) OR (aNumber <> editNum) THEN ∂
-
- Pos%(1) = (whichLine% - 1) * wholeBlockWidth% :∂
-
- WRITE 1, aName :∂ ' write edit text fields to file
-
- WRITE 1, aNumber :∂
-
- GOSUB getText ' write Com Control settings to file
-
-
-
- RETURN
-
-
-
-
-
- setEditText: ' set editing controls
-
- ButtonText(saveChanges%) = "Save Changes to " & Str(whichLine%)
-
- Pos%(1) = (whichLine% -1) * wholeBlockWidth%
-
- READ 1, editName
-
- READ 1, editNum
-
- ButtonText(startEdit%+1) = editNum
-
- DBoxResp(1) = editName
-
- RETURN
-
-
-
- doDial: ' dial the number
-
- Pos%(1) = (whichLine% -1) * wholeBlockWidth%
-
- READ 1, name
-
- READ 1, phoneNum
-
- CLEAR DBOX 406
-
- IF phoneNum <> "???" THEN ∂
-
- Pos%(1) = (whichLine% * wholeBlockWidth%) - paramBlockWidth% :∂
-
- GOSUB getSettings :∂
-
- commParams = Str(CommC.BPS%) & "," & Str(CommC.DBits%) & "," & Str(CommC.Parity%) & "," & Str(CommC.Sbits%) & "," & Str(CommC.XOnXOff%) :∂
-
- Message = phoneNum & "|" & commParams ∂
-
- ELSE ∂
-
- Message = "Dial called without a phone number.": ∂
-
- DISPLAY "Connect error: " & Message: ∂
-
- CLOSE 1: ∂
-
- END
-
- CLOSE 1
-
- HOLD OFF
-
- saveMessage = Message
-
- reDial: ' come back to here to redial
-
- DO FILE @modemFile "Dial"
-
- IF ResultCode% <> 0 THEN ∂
-
- badFile = @modemFile: ∂
-
- badLabel = "Dial": ∂
-
- GOSUB doFileError: ∂
-
- END
-
- IF Message <> "" THEN ∂
-
- IF @Redial% THEN ∂ ' if redial flag is set
-
- Message = saveMessage: ∂ ' using same phone number
-
- GOTO reDial ∂ ' dial again
-
- ELSE DISPLAY "Connect error: " & Message:RETURN
-
- Remark = name
-
- RETURN
-
-
-
-
-
- getText: ' reads names and numbers from file
-
- HOLD ON ' into strings, then sets static
-
- Pos%(1) = 0 ' text fields with those strings
-
- theLine% = 1
-
- theNames = ""
-
- theNumbers = ""
-
- getText1:
-
- READ 1, aName
-
- READ 1, aNumber
-
- theNames = theNames & Left(aName, 18) & Chr(13) & Chr(13)
-
- theNumbers = theNumbers & Left(aNumber, 18) & Chr(13) & Chr(13)
-
- IF theLine% < maxLines% THEN ∂
-
- Pos%(1) = theLine% * wholeBlockWidth% :∂
-
- theLine% = theLine% + 1 :∂
-
- GOTO getText1
-
- ButtonText(startText%) = theNames
-
- ButtonText(startText% + 1) = theNumbers
-
- RETURN
-
-
-
-
-
- saveSettings: ' saves current Com Control settings
-
- WRITE 1, TRUE% ' this is a flag to indicate settings are saved
-
- WRITE 1, CommC.Bit8%
-
- WRITE 1, CommC.BPS%
-
- WRITE 1, CommC.BSToDEL%
-
- WRITE 1, CommC.CharDelay%
-
- WRITE 1, CommC.Chars%
-
- WRITE 1, CommC.CharSet%
-
- WRITE 1, CommC.CurBlink%
-
- WRITE 1, CommC.CurShape%
-
- WRITE 1, CommC.DBits%
-
- WRITE 1, CommC.G0%
-
- WRITE 1, CommC.G1%
-
- WRITE 1, CommC.LFCRIn%
-
- WRITE 1, CommC.LFCROut%
-
- WRITE 1, CommC.LineDelay%
-
- WRITE 1, CommC.Lines%
-
- WRITE 1, CommC.LocEcho%
-
- WRITE 1, CommC.Parity%
-
- WRITE 1, CommC.Port%
-
- WRITE 1, CommC.Protocol%
-
- WRITE 1, CommC.ProtOpt%
-
- WRITE 1, CommC.RemEcho%
-
- WRITE 1, CommC.SBits%
-
- WRITE 1, CommC.Term%
-
- WRITE 1, CommC.Wrap%
-
- WRITE 1, CommC.XOnXOff%
-
- RETURN
-
-
-
- getSettings: ' saves current Comm Control settings
-
- READ 1, savedFlag% ' this is a flag to indicate settings were saved
-
- IF NOT savedFlag% THEN ∂
-
- RETURN
-
- READ 1, CommC.Bit8%
-
- READ 1, CommC.BPS%
-
- READ 1, CommC.BSToDEL%
-
- READ 1, CommC.CharDelay%
-
- READ 1, CommC.Chars%
-
- READ 1, CommC.CharSet%
-
- READ 1, CommC.CurBlink%
-
- READ 1, CommC.CurShape%
-
- READ 1, CommC.DBits%
-
- READ 1, CommC.G0%
-
- READ 1, CommC.G1%
-
- READ 1, CommC.LFCRIn%
-
- READ 1, CommC.LFCROut%
-
- READ 1, CommC.LineDelay%
-
- READ 1, CommC.Lines%
-
- READ 1, CommC.LocEcho%
-
- READ 1, CommC.Parity%
-
- READ 1, CommC.Port%
-
- READ 1, CommC.Protocol%
-
- READ 1, CommC.ProtOpt%
-
- READ 1, CommC.RemEcho%
-
- READ 1, CommC.SBits%
-
- READ 1, CommC.Term%
-
- READ 1, CommC.Wrap%
-
- READ 1, CommC.XOnXOff%
-
- RETURN
-
-
-
- makeFile: ' makes a fixed length file of <CR>'s
-
- OPEN 1, ServiceFPath & "MiniTerminalPhoneBook", APPEND
-
- IF ResultCode% <> 0 THEN ∂
-
- badFile = "MiniTerminalPhoneBook" : ∂
-
- GOSUB fileIO_Error: ∂
-
- END
-
- Pos%(1) = 0
-
- theSize% = wholeBlockWidth% * maxLines% + paramBlockWidth%
-
- filler = Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) ∂
-
- & Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) ∂
-
- & Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) ∂
-
- & Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) ∂
-
- & Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) ∂
-
- & Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) ∂
-
- & Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) ∂
-
- & Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) ∂
-
- & Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13) ∂
-
- & Chr(13) & Chr(13) & Chr(13) & Chr(13) & Chr(13)
-
- makeFile1:
-
- WRITE 1, filler
-
- IF Pos%(1) < theSize% THEN ∂
-
- GOTO makeFile1
-
- x% = 0
-
- makeFile2:
-
- IF x% < maxLines% THEN ∂
-
- Pos%(1) = wholeBlockWidth% * x% :∂
-
- WRITE 1, "???" :∂
-
- WRITE 1, "???" :∂
-
- x% = x% + 1 :∂
-
- GOTO makeFile2
-
- RETURN
-
-
-
- getModemFile: 'gets name of modem file and stores it in variable @modemFile
-
- HOLD ON
-
- Message = ""
-
- prompt1 = "Please select the modem file:"
-
- fileType1 = "SERV"
-
- HOLD OFF
-
- modemFile = GetFile(prompt1,fileType1,ServiceFPath)
-
- HOLD ON
-
- CURSOR WATCH
-
- IF (ResultCode% = 100) OR (DBoxResult% = CANCEL%) THEN END
-
-
-
- 'parse the path from string returned by GetFile
-
- myPath = modemFile
-
- lastColon% = 0
-
- getLastColon:
-
- IF InStr%(lastColon%+1, myPath, ":") <> 0 THEN ∂
-
- lastColon% = lastColon%+1: GOTO getLastColon
-
-
-
- myPath = Left(myPath,lastColon%)
-
- modemFile = Mid(modemFile, lastColon%+1)
-
-
-
- ServiceFPath = myPath ' set ServiceFPath to path returned by GetFile
-
- Message = ""
-
- DO FILE modemFile "Identify"
-
- IF (ResultCode% <> 0) THEN ∂
-
- IF (ResultCode% <> 106) THEN ∂ ' bad label error
-
- badFile = modemFile: ∂ ' 106 is "label not found" error
-
- badLabel = "Identify": ∂
-
- GOSUB doFileError: ∂
-
- END ∂
-
- ELSE Message = "NotModem" ' coerce dbox for error #106
-
-
-
- ' check for if modemFile is really a modem file
-
- IF UpCase(Message) <> "MODEM" THEN ∂
-
- DBoxSay = modemFile & " does not appear to be a modem file. " & ∂
-
- "An example of a modem file for Apple and " & ∂
-
- "Hayes-compatible modems is ""Hayes Modem."" Try again?": ∂
-
- HOLD OFF: ∂
-
- DBOX 2: ∂
-
- IF DBoxResult% = OK% THEN GOTO getModemFile ∂
-
- ELSE END
-
-
-
- ' check to see if modem file in Lookup Table is still there
-
- IF @ModemFile <> "" THEN ∂
-
- IF NOT Exists%(ServiceFPath & @modemFile) THEN CLEAR @modemFile ∂
-
- ELSE DO FILE @modemFile "ClearTable": ∂
-
- IF ResultCode% <> 0 THEN ∂ ' check for errors executing "DO FILE"
-
- badFile = @modemFile: ∂
-
- badLabel = "ClearTable": ∂
-
- GOSUB doFileError: ∂
-
- END
-
-
-
- @modemFile = modemFile ' put new modem file in lookup table
-
- Message = "" ' routine was successful
-
- RETURN
-
-
-
- doFileError: ' puts up error dialog and aborts
-
- HOLD OFF
-
- BELL:BELL ' alert user
-
- ' Give user a description of error
-
- IF ResultCode% = 106 THEN DBoxSay = "Cannot find the label """ & badLabel & ∂
-
- """ in the file """ & badFile & """. Program aborted." ∂
-
- ELSE IF ResultCode% = -108 THEN ∂
-
- DBoxSay = "Not enough memory to open the file """ & ∂
-
- badFile & """. Program aborted." ∂
-
- ELSE IF ResultCode% = -35 THEN ∂
-
- DBoxSay = "Cannot open the file """ & badFile & ∂
-
- """ because volume specified doesn't exist. Program aborted." ∂
-
- ELSE IF ResultCode% = -49 THEN ∂
-
- DBoxSay = "Cannot open the file """ & badFile & ∂
-
- """ because it is already open for writing. Program aborted." ∂
-
- ELSE IF ResultCode% = -47 THEN ∂
-
- DBoxSay = "Cannot open the file """ & badFile & ∂
-
- """ because it is busy. Program aborted." ∂
-
- ELSE DBoxSay = "The following error occurred during a call to """ & badLabel & ∂
-
- """ in the file """ & badFile & """: Macintosh error result code = " & ∂
-
- ResultCode% & ". Program aborted."
-
- DBOX 1
-
- RETURN
-
-
-
- fileIO_Error: ' puts up error dialog and aborts
-
- HOLD OFF
-
- BELL:BELL ' alert user
-
- ' Give user a description of error
-
- IF ResultCode% = -108 THEN ∂
-
- DBoxSay = "Not enough memory to open the file """ & ∂
-
- badFile & """. Program aborted." ∂
-
- ELSE IF ResultCode% = -49 THEN ∂
-
- DBoxSay = "Cannot open the file """ & badFile & ∂
-
- """ because it is already open for writing. Program aborted." ∂
-
- ELSE IF ResultCode% = -47 THEN ∂
-
- DBoxSay = "Cannot open the file """ & badFile & ∂
-
- """ because it is busy. Program aborted." ∂
-
- ELSE IF ResultCode% = -46 THEN ∂
-
- DBoxSay = "Cannot open the file """ & badFile & ∂
-
- """ because volume is locked by a software flag. Program aborted." ∂
-
- ELSE IF ResultCode% = -45 THEN ∂
-
- DBoxSay = "Cannot open the file """ & badFile & ∂
-
- """ because file is locked. Program aborted." ∂
-
- ELSE IF ResultCode% = -35 THEN ∂
-
- DBoxSay = "Cannot open the file """ & badFile & ∂
-
- """ because volume specified doesn't exist. Program aborted." ∂
-
- ELSE IF ResultCode% = -44 THEN ∂
-
- DBoxSay = "Cannot open the file """ & badFile & ∂
-
- """ because volume is locked by a hardware setting. Program aborted." ∂
-
- ELSE DBoxSay = "The following error occurred opening the file """ ∂
-
- & badFile & """: Macintosh error result code = " & ∂
-
- ResultCode% & ". Program aborted."
-
- DBOX 1
-
- RETURN
-
-
-
- Interrupt:
-
- CLEAR DBOX 406
-
- IF changedSettings% THEN ∂
-
- Pos%(1) = maxLines% * wholeBlockWidth% :∂
-
- GOSUB getSettings
-
- CLOSE 1
-
- LEAVE
-
-